python libs for all vis things


In [17]:
%pylab inline


Populating the interactive namespace from numpy and matplotlib
WARNING: pylab import has clobbered these variables: ['Text', 'Button', 'Widget', 'interactive']
`%matplotlib` prevents importing * from pylab and numpy

In [18]:
t = arange(0.0, 1.0, 0.01)

y1 = sin(2*pi*t)
y2 = sin(2*2*pi*t)

import pandas as pd

df = pd.DataFrame({'t': t, 'y1': y1, 'y2': y2})
df.head(10)


Out[18]:
t y1 y2
0 0.00 0.000000 0.000000
1 0.01 0.062791 0.125333
2 0.02 0.125333 0.248690
3 0.03 0.187381 0.368125
4 0.04 0.248690 0.481754
5 0.05 0.309017 0.587785
6 0.06 0.368125 0.684547
7 0.07 0.425779 0.770513
8 0.08 0.481754 0.844328
9 0.09 0.535827 0.904827

In [19]:
fig = figure(1, figsize = (10,10))

ax1 = fig.add_subplot(211)
ax1.plot(t, y1)
ax1.grid(True)
ax1.set_ylim((-2, 2))
ax1.set_ylabel('Gentle Lull')
ax1.set_title('I can plot waves')

for label in ax1.get_xticklabels():
    label.set_color('r')


ax2 = fig.add_subplot(212)
ax2.plot(t, y2,)
ax2.grid(True)
ax2.set_ylim((-2, 2))
ax2.set_ylabel('Getting choppier')
l = ax2.set_xlabel('Hi PyLadies')
l.set_color('g')
l.set_fontsize('large')

show()



In [20]:
import seaborn as sns

sns.set(color_codes=True)
sns.distplot(y1)
sns.distplot(y2)


Out[20]:
<matplotlib.axes._subplots.AxesSubplot at 0x112314d10>

ipywidgets

  • helpful tutorial here

with matplotlib


In [21]:
from ipywidgets import widgets
from IPython.html.widgets import *

t = arange(0.0, 1.0, 0.01)

def pltsin(f):
    plt.plot(t, sin(2*pi*t*f))
    
interact(pltsin, f=(1,10,0.1))


with seaborn!


In [22]:
def pltsin(f):
    sns.distplot(sin(2*pi*t*f))
    
interact(pltsin, f=(1,10,0.1))


others to check out